home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ansi
/
help_7n1.zip
/
HELP.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-10-02
|
22KB
|
816 lines
;from VOL7N1.ARC, PC Magazine Jan 88?
; Help.asm
; Resident help facility
; Format: HELP filespec [... filespec][/Nn][/P][/Hn] | [/U]
; defaults: pages = 4; hot key = Alt H
CODE SEGMENT ;********************************;
ASSUME CS:CODE,DS:CODE ;* *;
ORG 100H ;* Requires MASM 2.0 or later *;
;* Remember to EXE2BIN *;
START: JMP BEGINNING ;* *;
;********************************;
; DATA AREA
; ---------
COPYRIGHT DB "HELP 1.0 (c) 1987 Ziff Communications Co.",13,10
DB "Successfully installed",13,10
ALT_COMBO DB "Press Alt H to activate",10,0,26
PROGRAMMER DB "Michael J. Mefford"
OLD_KEYBOARD DD ?
CRT_COLS DW ?
STATUS_REG DW ?
SCREEN_SEG DW 0B000H
LINE_COUNT DB 25
IMMEDIATE_FLAG DB 0
BUSY DB 0
IMMEDIATE DW POP_IT
DATA_SEG DW ?
DATA_INT DB 0
INSTALLED_FLAG DB 0
POPUP_FLAG DB 0
HOT_KEY DB 35
FILENAME DW ?
ERROR_LEVEL DB 0
CURRENT_PAGE DB 1
RESERVED_PAGES DB 4
ACTIVE_PAGES DB 0
PAGE_COUNT DB 0
DELIMITERS DB 9,32,13,44,";","/"
SYNTAX LABEL BYTE
DB 10,"Usage: HELP filespec [... filespec][/Nn][/Hn][/P] | [/U]",13,10,10
DB "/Nn where n = number of reserved pages (1-14); default = 4",13,10
DB "/Hn where n = Alt hot key combo (A-Z,0-9,",34,45,34,44,34,61,34
DB "); default = H",13,10
DB "/P = immediate pop-up",13,10
DB "/U = uninstall",13,10,10
DB "Use: PgUp PgDn Home End to navigate through HELP",13,10
DB 5 DUP(32),"ESC or hot key to exit",10,0
ACTIVE_MSG DB " active page(s)",13,10,0
RESERVED_MSG DB " total page(s)",13,10,10,0
UNLOAD_MSG DB 10,"HELP can't be uninstalled.",13,10
DB "Uninstall resident programs in reverse order.",10,0
UNINSTALL_MSG DB 10,"HELP uninstalled",10,0
NO_FREE DB "Too many resident programs",0
NOT_FOUND DB 32,"not found",13,10,0
NOT_ENOUGH DB "Not enough memory",0
ALLOCATE_MSG DB "Memory allocation error",13,10,0
SCAN_CODES LABEL BYTE
DB 45,130,48,129,49,120,50,121,51,122,52,123,53,124
DB 54,125,55,126,56,127,57,128,61,131,65,30,66,48,67
DB 46,68,32,69,18,70,33,71,34,72,35,73,23,74,36,75,37
DB 76,38,77,50,78,49,79,24,80,25,81,16,82,19,83,31
DB 84,20,85,22,86,47,87,17,88,45,89,21,90,44
; SCAN CODES FOR ALT COMBO
;
; Code Key Code Key Code Key Code Key
; 16 Q 30 A 44 Z 120 1
; 17 W 31 S 45 X 121 2
; 18 E 32 D 46 C 122 3
; 19 R 33 F 47 V 123 4
; 20 T 34 G 48 B 124 5
; 21 Y 35 H 49 N 125 6
; 22 U 36 J 50 M 126 7
; 23 I 37 K 127 8
; 24 O 38 L 128 9
; 25 P 129 0
; 130 -
; Default is 35 (Alt H) 131 =
;************* KEYBOARD INTERCEPTOR *************;
NEW_KEYBOARD:
STI
PUSHF ;Simulate an interrupt
CALL CS:OLD_KEYBOARD ; by pushing flags and far call.
POP_IT: PUSHF ;On return save all registers
PUSH DS ; that will be used.
PUSH ES
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH BP
PUSH CS ;Point to our data.
POP DS
CLD ;Moves in forward direction.
MOV AX,40H ;Point to ROM BIOS data area
MOV ES,AX
MOV AX,ES:[4AH] ;Get number of columns on screen
MOV CRT_COLS,AX ; and store.
MOV AX,ES:[63H] ;Get base address of video card.
ADD AX,6 ;Convert to status register
MOV STATUS_REG,AX ; and store.
CMP AX,3BAH ;Is it mono card?
JZ MONO ;If yes, use b800h.
MOV SCREEN_SEG,0B800H ; else point to color card.
MONO: MOV AL,ES:[49H] ;Retrieve video mode.
CMP AL,3 ;Is it text mode?
JBE GOOD_MODE ;If yes, OK.
CMP AL,7
JNZ DONE_HERE ;Exit if graphics
GOOD_MODE:
CMP IMMEDIATE_FLAG,1 ;Is there a pop-up request?
JZ NOW ;If yes, pop-up right now.
CMP BUSY,1 ;If the window is already popped
JZ DONE_HERE ; exit Int 9 back to window.
MOV AH,1 ;Is an ASCII character ready?
INT 16H
JZ DONE_HERE ;If it's just a key release, exit.
CMP AL,0 ;Is it extended code?
JNZ DONE_HERE ;If no, exit.
CMP AH,HOT_KEY ;Else, see if our Alt key combo.
JZ OPEN_WINDOW ;If yes, open window
DONE_HERE:
JMP SHORT EXIT_KEYBOARD ; else exit.
;------------------------------------;
; Save screen so we can pop up HELP. ;
;------------------------------------;
OPEN_WINDOW:
MOV AH,0 ;Retrieve and discard hot key
INT 16H ; character from keyboard buffer.
NOW: MOV BUSY,1 ;Flag that window is open.
MOV IMMEDIATE_FLAG,0 ;Restore immediate flag.
CALL STORE_SCREEN ;Store screen.
;-----------------------------------------;
; Loop here looking for valid keystrokes. ;
;-----------------------------------------;
READ_KEY:
MOV CL,CURRENT_PAGE ;Get current page.
DEC CL ;Adjust for starting offset.
CALL PAGE_SIZE ;Get offset.
MOV SI,DX
CALL WRITE_SCREEN ;Update the screen.
MOV AH,0 ;Wait for a character.
INT 16H
CMP AH,1 ;Is it Esc?
JZ EXIT_WINDOW ;If yes, exit window.
CMP AH,BYTE PTR HOT_KEY ;Is it our key combo?
JZ EXIT_WINDOW ;If yes, exit window.
MOV CL,CURRENT_PAGE ;Get current page.
CMP AH,49H ;Is it PgUp?
JNZ CK_PGDN
CMP CL,1 ;If yes, is it already page one?
JZ END_KEY
DEC CL ;If no, decrement page.
CK_PGDN:
CMP AH,51H ;Is it PgDn?
JNZ CK_HOME
CMP CL,ACTIVE_PAGES ;If yes, are we already last page?
JZ END_KEY
INC CL ;If no, increment page.
CK_HOME:
CMP AH,47H ;Is it Home?
JNZ CK_END
MOV CL,1 ;If yes, move to page one.
CK_END: CMP AH,4FH ;Is it End?
JNZ END_KEY
MOV CL,ACTIVE_PAGES ;If yes, move to last page.
END_KEY:
MOV CURRENT_PAGE,CL ;Store new current page.
JMP SHORT READ_KEY
;----------------------------------;
; This is the window exit routine. ;
;----------------------------------;
EXIT_WINDOW:
MOV SI,OFFSET SCREEN_BUFFER ;Point to the stored screen
CALL WRITE_SCREEN ; and restore the screen.
MOV IMMEDIATE_FLAG,0 ;Reset the pop-up flag.
MOV BUSY,0 ;Flag done with window.
EXIT_KEYBOARD:
POP BP ;Restore all registers.
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
POP ES
POP DS
POPF
IRET ;Return from interrupt.
;************* FILE LOADING AND INSTALL PROCEDURE *************;
BEGINNING:
CLD
PUSH CS
POP DATA_SEG ;Store our segment.
CMP SP,65533 ;Do we have 64K?
JA CK_PARA
MOV SI,OFFSET NOT_ENOUGH ;If no, exit with message.
JMP ERROR_EXIT
CK_PARA:
CMP BYTE PTR DS:[80H],0 ;Any parameters?
JNZ CK_FREE
OPTIONS:
MOV SI,OFFSET SYNTAX ;If no, exit with syntax message.
JMP ERROR_EXIT
;----------------------------------------------------------------------;
; Check user vectors to see if we are installed or if one is available ;
;----------------------------------------------------------------------;
CK_FREE:
MOV AL,60H - 1 ;Available vectors are 60H - 67H.
FREE_USER_INT:
INC AL
MOV AH,35H ;Get vector address.
INT 21H
CMP BX,0 ;Is offset being used?
JNZ CK_SIGNATURE ;If yes, see if it's us.
MOV DX,ES
or dx,dx ;CMP DX,0 ;Is segment being used?
JNZ CK_SIGNATURE ;If yes, see if it's us.
MOV DATA_INT,AL ;If available, save INT number.
NEXT_USER:
CMP AL,67H ;Have we checked all 7?
JNZ FREE_USER_INT ;If no, next one.
JMP SHORT CK_SWITCHES
CK_SIGNATURE:
MOV DI,BX ;See if INT has our signature.
MOV SI,100H
MOV CX,30/2
REPZ CMPSW
JNZ NEXT_USER ;If yes, already installed.
MOV DATA_SEG,ES ;Save segment.
MOV INSTALLED_FLAG,1
;--------------------------------------------;
; Check the command line for switch options. ;
;--------------------------------------------;
CK_SWITCHES:
PUSH DATA_SEG ;First point to installed segment.
POP ES
MOV SI,81H ;First parameter.
NEXT_SWITCH:
LODSB ;Get a byte.
CMP AL,13 ;Is it carriage return?
JZ CK_FILENAMES ;If yes, done here.
CMP AL,"/" ;Is it switch character?
JNZ NEXT_SWITCH ;If no, get next byte
LODSB ; else get switch.
CMP AL,13 ;Is it carriage return?
JZ CK_FILENAMES ;If yes, done here
CALL CAPITALIZE ; else capitalize.
CMP AL,"U" ;Is it "U"?
JNZ CK_N
CMP INSTALLED_FLAG,1 ;If yes, are we installed?
JNZ NEXT_SWITCH
JMP UNINSTALL ;If yes, uninstall.
CK_N:
CMP AL,"N" ;Is it "N"?
JNZ CK_P
CMP INSTALLED_FLAG,1 ;If yes, are we installed?
JZ NE